package com.zc.study;

import org.apache.poi.ss.formula.functions.T;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.FutureTask;

public class ThreadTest {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
         /*new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("a1");
            }
        }).run();
         new Thread(new Runnable() {
            @Override
            public void run() {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                System.out.println("a2");
            }
        }).run();
         new Thread(new Runnable() {
            @Override
            public void run() {
                System.out.println("a3");
            }
        }).run();*/
        FutureTask<String> ft = new FutureTask<String>(new Thread3());
        Thread a = new Thread(ft);
        a.start();

            System.out.println(ft.get());

    }

    static class Thread3 implements Callable<String>{

        @Override
        public String call() throws Exception {
            Thread.sleep(5000);
            System.out.println("c running ");
            return "3";
        }
    }
}
